#include"faststring.h"
#include<string.h>

IFastString* CreateFastString(const char* psz){
    //return new FastString(psz);
    //new version
    IFastString* p = new FastString(psz);
    if(p)
        p->DuplicatePointer();
    return p;
}

FastString::FastString(const char* sz):m_ch(strlen(sz),m_psz(new char[m_ch+1])
{
    strcpy(m_psz,sz);
}

FastString::~FastString(){
    delete[] m_psz;
}

void FastString::Delete(){
    delete this;
}

int FastString::Length() const{
    return m_ch;
}

int FastString::Find(const char* sz) const{
    return 1;
}

void *FastString::Dynamic_Cast(const char* type){
    void *pResult=0;
    if(!strcmp(type,"IFastString"))
        pResult = static_cast<IFastString*>(this);
    else if(!strcmp(type,"IPersistentObject"))
        pResult=static_cast<IPersistentObject*>(this);
    else if(!strcmp(type,"IExtensibleObject"))
        pResult=static_cast<IFastString*>(this);
    else
        return 0;
    ((IExtensibleObject*)pResult)->DuplicatePointer();
    return pResult;
}
